package com.bbs.test;

import com.bbs.dao.PostDao;
import com.bbs.dao.UserDao;
import com.bbs.entity.Post;
import com.bbs.service.testUserService;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.io.IOException;
import java.io.InputStream;

public class testLei {
    private InputStream resourceAsStream;
    private SqlSession sqlSession;
    private UserDao userDao;
    private PostDao postDao;
//    @Before
//    public void init()throws Exception{
//        //加载核心配置文件classpath:applicationContext.xml/SqlMapConfig.xml
//        resourceAsStream = Resources.getResourceAsStream("SqlMapConfig.xml");
//        //获得sqlSession工厂对象
//        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);
//        //获得sqlSession对象
//        sqlSession = sqlSessionFactory.openSession();
//        //执行sql语句
//        postDao = sqlSession.getMapper(PostDao.class);
//    }
//    @After
//    public void destroy()throws Exception{
//        sqlSession.commit();
//        //释放资源
//        sqlSession.close();
//        resourceAsStream.close();
//    }
//    @Test
//    public void test1(){
//        Post byId = postDao.findById(1);
//        System.out.println(byId);
//    }
@Autowired
private testUserService userService;
    @Test
    public void test1(){
        userService.save();
    }

}
